package com.huitone.smspfm.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.util.StringUtils;

public class SmsEntifyForCallTest {

	private StringRedisSerializer serializer = new StringRedisSerializer();
	private String recId;
	private String testPhone;
	private String gateLinkId;
	private String sendTime;
	private String sendResult;
	private String smSeq;
	private String testContent;

	public static final class Key {
		public final static String REC_ID = "recId";
		public final static String TEST_PHONE = "testPhone";
		public final static String TEST_CONTENT = "testContent";
		public final static String GATE_LINK_ID = "gateLinkId";
		public final static String SEND_TIME = "sendTime";
		public final static String SEND_RESULT = "sendResult";
		public final static String SM_SEQ = "smSeq";
	}

	public String getRecId() {
		return recId;
	}

	public void setRecId(String recId) {
		this.recId = recId;
	}

	public String getTestPhone() {
		return testPhone;
	}

	public void setTestPhone(String testPhone) {
		this.testPhone = testPhone;
	}

	public String getGateLinkId() {
		return gateLinkId;
	}

	public void setGateLinkId(String gateLinkId) {
		this.gateLinkId = gateLinkId;
	}

	public String getSendTime() {
		return sendTime;
	}

	public void setSendTime(String sendTime) {
		this.sendTime = sendTime;
	}

	public String getSendResult() {
		return sendResult;
	}

	public void setSendResult(String sendResult) {
		this.sendResult = sendResult;
	}

	public String getSmSeq() {
		return smSeq;
	}

	public void setSmSeq(String smSeq) {
		this.smSeq = smSeq;
	}

	public String getTestContent() {
		return testContent;
	}

	public void setTestContent(String testContent) {
		this.testContent = testContent;
	}

	public Map<byte[], byte[]> toMap() {
		Map<byte[], byte[]> result = new HashMap<byte[], byte[]>();
		if (!StringUtils.isEmpty(this.getRecId()))
			result.put(serializer.serialize(Key.REC_ID),
					serializer.serialize(this.getRecId()));
		if (!StringUtils.isEmpty(this.getGateLinkId()))
			result.put(serializer.serialize(Key.GATE_LINK_ID),
					serializer.serialize(this.getGateLinkId()));
		if (!StringUtils.isEmpty(this.getSendResult()))
			result.put(serializer.serialize(Key.SEND_RESULT),
					serializer.serialize(this.getSendResult()));
		if (!StringUtils.isEmpty(this.getSendTime()))
			result.put(serializer.serialize(Key.SEND_TIME),
					serializer.serialize(this.getSendTime()));
		if (!StringUtils.isEmpty(this.getSmSeq()))
			result.put(serializer.serialize(Key.SM_SEQ),
					serializer.serialize(this.getSmSeq()));
		if (!StringUtils.isEmpty(this.getTestContent()))
			result.put(serializer.serialize(Key.TEST_CONTENT),
					serializer.serialize(this.getTestContent()));
		if (!StringUtils.isEmpty(this.getTestPhone()))
			result.put(serializer.serialize(Key.TEST_PHONE),
					serializer.serialize(this.getTestPhone()));

		return result;
	}
	
	public static SmsEntifyForCallTest parse(List<String> list){
		if(list == null || list.size() < 7){
			return null;
		}
		SmsEntifyForCallTest sms= new SmsEntifyForCallTest();
		sms.setRecId(list.get(0));
		sms.setTestPhone(list.get(1));
		sms.setTestContent(list.get(2));
		sms.setGateLinkId(list.get(3));
		sms.setSendTime(list.get(4));
		sms.setSendResult(list.get(5));
		sms.setSmSeq(list.get(6));
		
		
		
		return sms;
	}
}
